<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP, DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses #-}</span><span class="hs-cpp">

#if __GLASGOW_HASKELL__ &gt;= 701
</span><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-7"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Module      :  Control.Concurrent.STM.TArray</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2005</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- </span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Stability   :  experimental</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Portability :  non-portable (requires STM)</span><span>
</span><span id="line-16"></span><span class="hs-comment">--</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- TArrays: transactional arrays, for use in the STM monad</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Control.Concurrent.STM.TArray</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-22"></span><span>    </span><span class="annot"><a href="Control.Concurrent.STM.TArray.html#TArray"><span class="hs-identifier">TArray</span></a></span><span>
</span><span id="line-23"></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.html#"><span class="hs-identifier">Data.Array</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Arr.html#Array"><span class="hs-identifier">Array</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Arr.html#bounds"><span class="hs-identifier">bounds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.Base.html#"><span class="hs-identifier">Data.Array.Base</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../array/src/Data.Array.Base.html#listArray"><span class="hs-identifier">listArray</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.Base.html#arrEleBottom"><span class="hs-identifier">arrEleBottom</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.Base.html#unsafeAt"><span class="hs-identifier">unsafeAt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.Base.html#MArray"><span class="hs-identifier">MArray</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>                        </span><span class="annot"><a href="../../array/src/Data.Array.Base.html#IArray"><span class="hs-identifier">IArray</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../array/src/Data.Array.Base.html#numElements"><span class="hs-identifier">numElements</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Ix.html#"><span class="hs-identifier">Data.Ix</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ix.html#rangeSize"><span class="hs-identifier">rangeSize</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.html#"><span class="hs-identifier">Data.Typeable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier">Typeable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TVar.html"><span class="hs-identifier">Control.Concurrent.STM.TVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#TVar"><span class="hs-identifier">TVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier">newTVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier">readTVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#writeTVar"><span class="hs-identifier">writeTVar</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#ifdef __GLASGOW_HASKELL__
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.html#"><span class="hs-identifier">GHC.Conc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier">STM</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Control.Sequential.STM</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">STM</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-37"></span><span class="hs-comment">-- |TArray is a transactional array, supporting the usual 'MArray'</span><span>
</span><span id="line-38"></span><span class="hs-comment">-- interface for mutable arrays.</span><span>
</span><span id="line-39"></span><span class="hs-comment">--</span><span>
</span><span id="line-40"></span><span class="hs-comment">-- It is currently implemented as @Array ix (TVar e)@,</span><span>
</span><span id="line-41"></span><span class="hs-comment">-- but it may be replaced by a more efficient implementation in the future</span><span>
</span><span id="line-42"></span><span class="hs-comment">-- (the interface will remain the same, however).</span><span>
</span><span id="line-43"></span><span class="hs-comment">--</span><span>
</span><span id="line-44"></span><span class="hs-keyword">newtype</span><span> </span><span id="TArray"><span class="annot"><a href="Control.Concurrent.STM.TArray.html#TArray"><span class="hs-identifier hs-var">TArray</span></a></span></span><span> </span><span id="local-6989586621679037641"><span class="annot"><a href="#local-6989586621679037641"><span class="hs-identifier hs-type">i</span></a></span></span><span> </span><span id="local-6989586621679037640"><span class="annot"><a href="#local-6989586621679037640"><span class="hs-identifier hs-type">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="TArray"><span class="annot"><a href="Control.Concurrent.STM.TArray.html#TArray"><span class="hs-identifier hs-var">TArray</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Arr.html#Array"><span class="hs-identifier hs-type">Array</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037641"><span class="hs-identifier hs-type">i</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#TVar"><span class="hs-identifier hs-type">TVar</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037640"><span class="hs-identifier hs-type">e</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679037573"><span id="local-6989586621679037579"><span class="annot"><span class="annottext">TArray i e -&gt; TArray i e -&gt; Bool
(TArray i e -&gt; TArray i e -&gt; Bool)
-&gt; (TArray i e -&gt; TArray i e -&gt; Bool) -&gt; Eq (TArray i e)
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
forall i e. Ix i =&gt; TArray i e -&gt; TArray i e -&gt; Bool
/= :: TArray i e -&gt; TArray i e -&gt; Bool
$c/= :: forall i e. Ix i =&gt; TArray i e -&gt; TArray i e -&gt; Bool
== :: TArray i e -&gt; TArray i e -&gt; Bool
$c== :: forall i e. Ix i =&gt; TArray i e -&gt; TArray i e -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span id="local-6989586621679037630"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679037558"><span class="annot"><a href="../../array/src/Data.Array.Base.html#MArray"><span class="hs-identifier hs-type">MArray</span></a></span><span> </span><span class="annot"><a href="Control.Concurrent.STM.TArray.html#TArray"><span class="hs-identifier hs-type">TArray</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037630"><span class="hs-identifier hs-type">e</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Conc.Sync.html#STM"><span class="hs-identifier hs-type">STM</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-47"></span><span>    </span><span id="local-6989586621679037552"><span class="annot"><span class="annottext">getBounds :: forall i. Ix i =&gt; TArray i e -&gt; STM (i, i)
</span><a href="../../array/src/Data.Array.Base.html#getBounds"><span class="hs-identifier hs-var hs-var hs-var hs-var">getBounds</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TArray.html#TArray"><span class="hs-identifier hs-type">TArray</span></a></span><span> </span><span id="local-6989586621679037550"><span class="annot"><span class="annottext">Array i (TVar e)
</span><a href="#local-6989586621679037550"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(i, i) -&gt; STM (i, i)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Array i (TVar e) -&gt; (i, i)
forall i e. Array i e -&gt; (i, i)
</span><a href="../../base/src/GHC.Arr.html#bounds"><span class="hs-identifier hs-var">bounds</span></a></span><span> </span><span class="annot"><span class="annottext">Array i (TVar e)
</span><a href="#local-6989586621679037550"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-48"></span><span>    </span><span id="local-6989586621679037541"><span class="annot"><span class="annottext">newArray :: forall i. Ix i =&gt; (i, i) -&gt; e -&gt; STM (TArray i e)
</span><a href="../../array/src/Data.Array.Base.html#newArray"><span class="hs-identifier hs-var hs-var hs-var hs-var">newArray</span></a></span></span><span> </span><span id="local-6989586621679037539"><span class="annot"><span class="annottext">(i, i)
</span><a href="#local-6989586621679037539"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621679037538"><span class="annot"><span class="annottext">e
</span><a href="#local-6989586621679037538"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-49"></span><span>        </span><span id="local-6989586621679037537"><span class="annot"><span class="annottext">[TVar e]
</span><a href="#local-6989586621679037537"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; STM (TVar e) -&gt; STM [TVar e]
forall (m :: * -&gt; *) a. Monad m =&gt; Int -&gt; m a -&gt; m [a]
</span><a href="Control.Concurrent.STM.TArray.html#rep"><span class="hs-identifier hs-var">rep</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(i, i) -&gt; Int
forall a. Ix a =&gt; (a, a) -&gt; Int
</span><a href="../../base/src/GHC.Ix.html#rangeSize"><span class="hs-identifier hs-var">rangeSize</span></a></span><span> </span><span class="annot"><span class="annottext">(i, i)
</span><a href="#local-6989586621679037539"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">e -&gt; STM (TVar e)
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="annot"><span class="annottext">e
</span><a href="#local-6989586621679037538"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-50"></span><span>        </span><span class="annot"><span class="annottext">TArray i e -&gt; STM (TArray i e)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TArray i e -&gt; STM (TArray i e)) -&gt; TArray i e -&gt; STM (TArray i e)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Array i (TVar e) -&gt; TArray i e
forall i e. Array i (TVar e) -&gt; TArray i e
</span><a href="Control.Concurrent.STM.TArray.html#TArray"><span class="hs-identifier hs-var">TArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(i, i) -&gt; [TVar e] -&gt; Array i (TVar e)
forall (a :: * -&gt; * -&gt; *) e i.
(IArray a e, Ix i) =&gt;
(i, i) -&gt; [e] -&gt; a i e
</span><a href="../../array/src/Data.Array.Base.html#listArray"><span class="hs-identifier hs-var">listArray</span></a></span><span> </span><span class="annot"><span class="annottext">(i, i)
</span><a href="#local-6989586621679037539"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">[TVar e]
</span><a href="#local-6989586621679037537"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span>    </span><span id="local-6989586621679037528"><span class="annot"><span class="annottext">newArray_ :: forall i. Ix i =&gt; (i, i) -&gt; STM (TArray i e)
</span><a href="../../array/src/Data.Array.Base.html#newArray_"><span class="hs-identifier hs-var hs-var hs-var hs-var">newArray_</span></a></span></span><span> </span><span id="local-6989586621679037526"><span class="annot"><span class="annottext">(i, i)
</span><a href="#local-6989586621679037526"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-52"></span><span>        </span><span id="local-6989586621679037525"><span class="annot"><span class="annottext">[TVar e]
</span><a href="#local-6989586621679037525"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; STM (TVar e) -&gt; STM [TVar e]
forall (m :: * -&gt; *) a. Monad m =&gt; Int -&gt; m a -&gt; m [a]
</span><a href="Control.Concurrent.STM.TArray.html#rep"><span class="hs-identifier hs-var">rep</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(i, i) -&gt; Int
forall a. Ix a =&gt; (a, a) -&gt; Int
</span><a href="../../base/src/GHC.Ix.html#rangeSize"><span class="hs-identifier hs-var">rangeSize</span></a></span><span> </span><span class="annot"><span class="annottext">(i, i)
</span><a href="#local-6989586621679037526"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">e -&gt; STM (TVar e)
forall a. a -&gt; STM (TVar a)
</span><a href="../../base/src/GHC.Conc.Sync.html#newTVar"><span class="hs-identifier hs-var">newTVar</span></a></span><span> </span><span class="annot"><span class="annottext">e
forall a. a
</span><a href="../../array/src/Data.Array.Base.html#arrEleBottom"><span class="hs-identifier hs-var">arrEleBottom</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span>        </span><span class="annot"><span class="annottext">TArray i e -&gt; STM (TArray i e)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TArray i e -&gt; STM (TArray i e)) -&gt; TArray i e -&gt; STM (TArray i e)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Array i (TVar e) -&gt; TArray i e
forall i e. Array i (TVar e) -&gt; TArray i e
</span><a href="Control.Concurrent.STM.TArray.html#TArray"><span class="hs-identifier hs-var">TArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(i, i) -&gt; [TVar e] -&gt; Array i (TVar e)
forall (a :: * -&gt; * -&gt; *) e i.
(IArray a e, Ix i) =&gt;
(i, i) -&gt; [e] -&gt; a i e
</span><a href="../../array/src/Data.Array.Base.html#listArray"><span class="hs-identifier hs-var">listArray</span></a></span><span> </span><span class="annot"><span class="annottext">(i, i)
</span><a href="#local-6989586621679037526"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">[TVar e]
</span><a href="#local-6989586621679037525"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span>    </span><span id="local-6989586621679037521"><span class="annot"><span class="annottext">unsafeRead :: forall i. Ix i =&gt; TArray i e -&gt; Int -&gt; STM e
</span><a href="../../array/src/Data.Array.Base.html#unsafeRead"><span class="hs-identifier hs-var hs-var hs-var hs-var">unsafeRead</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TArray.html#TArray"><span class="hs-identifier hs-type">TArray</span></a></span><span> </span><span id="local-6989586621679037519"><span class="annot"><span class="annottext">Array i (TVar e)
</span><a href="#local-6989586621679037519"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679037518"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679037518"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TVar e -&gt; STM e
forall a. TVar a -&gt; STM a
</span><a href="../../base/src/GHC.Conc.Sync.html#readTVar"><span class="hs-identifier hs-var">readTVar</span></a></span><span> </span><span class="annot"><span class="annottext">(TVar e -&gt; STM e) -&gt; TVar e -&gt; STM e
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Array i (TVar e) -&gt; Int -&gt; TVar e
forall (a :: * -&gt; * -&gt; *) e i.
(IArray a e, Ix i) =&gt;
a i e -&gt; Int -&gt; e
</span><a href="../../array/src/Data.Array.Base.html#unsafeAt"><span class="hs-identifier hs-var">unsafeAt</span></a></span><span> </span><span class="annot"><span class="annottext">Array i (TVar e)
</span><a href="#local-6989586621679037519"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679037518"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-55"></span><span>    </span><span id="local-6989586621679037514"><span class="annot"><span class="annottext">unsafeWrite :: forall i. Ix i =&gt; TArray i e -&gt; Int -&gt; e -&gt; STM ()
</span><a href="../../array/src/Data.Array.Base.html#unsafeWrite"><span class="hs-identifier hs-var hs-var hs-var hs-var">unsafeWrite</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TArray.html#TArray"><span class="hs-identifier hs-type">TArray</span></a></span><span> </span><span id="local-6989586621679037512"><span class="annot"><span class="annottext">Array i (TVar e)
</span><a href="#local-6989586621679037512"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679037511"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679037511"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span id="local-6989586621679037510"><span class="annot"><span class="annottext">e
</span><a href="#local-6989586621679037510"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TVar e -&gt; e -&gt; STM ()
forall a. TVar a -&gt; a -&gt; STM ()
</span><a href="../../base/src/GHC.Conc.Sync.html#writeTVar"><span class="hs-identifier hs-var">writeTVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Array i (TVar e) -&gt; Int -&gt; TVar e
forall (a :: * -&gt; * -&gt; *) e i.
(IArray a e, Ix i) =&gt;
a i e -&gt; Int -&gt; e
</span><a href="../../array/src/Data.Array.Base.html#unsafeAt"><span class="hs-identifier hs-var">unsafeAt</span></a></span><span> </span><span class="annot"><span class="annottext">Array i (TVar e)
</span><a href="#local-6989586621679037512"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679037511"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">e
</span><a href="#local-6989586621679037510"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-56"></span><span>    </span><span id="local-6989586621679037505"><span class="annot"><span class="annottext">getNumElements :: forall i. Ix i =&gt; TArray i e -&gt; STM Int
</span><a href="../../array/src/Data.Array.Base.html#getNumElements"><span class="hs-identifier hs-var hs-var hs-var hs-var">getNumElements</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Control.Concurrent.STM.TArray.html#TArray"><span class="hs-identifier hs-type">TArray</span></a></span><span> </span><span id="local-6989586621679037503"><span class="annot"><span class="annottext">Array i (TVar e)
</span><a href="#local-6989586621679037503"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; STM Int
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Array i (TVar e) -&gt; Int
forall (a :: * -&gt; * -&gt; *) e i. (IArray a e, Ix i) =&gt; a i e -&gt; Int
</span><a href="../../array/src/Data.Array.Base.html#numElements"><span class="hs-identifier hs-var">numElements</span></a></span><span> </span><span class="annot"><span class="annottext">Array i (TVar e)
</span><a href="#local-6989586621679037503"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span class="hs-comment">-- | Like 'replicateM' but uses an accumulator to prevent stack overflows.</span><span>
</span><span id="line-59"></span><span class="hs-comment">-- Unlike 'replicateM' the returned list is in reversed order.</span><span>
</span><span id="line-60"></span><span class="hs-comment">-- This doesn't matter though since this function is only used to create</span><span>
</span><span id="line-61"></span><span class="hs-comment">-- arrays with identical elements.</span><span>
</span><span id="line-62"></span><span id="local-6989586621679037620"><span id="local-6989586621679037621"><span class="annot"><a href="Control.Concurrent.STM.TArray.html#rep"><span class="hs-identifier hs-type">rep</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037621"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679037621"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679037620"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679037621"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679037620"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span></span><span>
</span><span id="line-63"></span><span id="rep"><span class="annot"><span class="annottext">rep :: forall (m :: * -&gt; *) a. Monad m =&gt; Int -&gt; m a -&gt; m [a]
</span><a href="Control.Concurrent.STM.TArray.html#rep"><span class="hs-identifier hs-var hs-var">rep</span></a></span></span><span> </span><span id="local-6989586621679037497"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679037497"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621679037496"><span class="annot"><span class="annottext">m a
</span><a href="#local-6989586621679037496"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [a] -&gt; m [a]
forall {t}. (Eq t, Num t) =&gt; t -&gt; [a] -&gt; m [a]
</span><a href="#local-6989586621679037495"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679037497"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-64"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-65"></span><span>      </span><span id="local-6989586621679037495"><span class="annot"><span class="annottext">go :: t -&gt; [a] -&gt; m [a]
</span><a href="#local-6989586621679037495"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="annot"><span class="annottext">t
</span><span class="hs-number">0</span></span><span> </span><span id="local-6989586621679037486"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679037486"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; m [a]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679037486"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-66"></span><span>      </span><span class="annot"><a href="#local-6989586621679037495"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621679037485"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679037485"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span id="local-6989586621679037484"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679037484"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-67"></span><span>          </span><span id="local-6989586621679037483"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037483"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">m a
</span><a href="#local-6989586621679037496"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-68"></span><span>          </span><span class="annot"><span class="annottext">t -&gt; [a] -&gt; m [a]
</span><a href="#local-6989586621679037495"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679037485"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">t -&gt; t -&gt; t
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">t
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679037483"><span class="hs-identifier hs-var">x</span></a></span><span class="annot"><span class="annottext">a -&gt; [a] -&gt; [a]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679037484"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-69"></span></pre></body></html>